
# -*- coding:utf-8 -*-
import urllib2
import re

response = urllib2.urlopen('http://www.12306.cn/mormhweb/zxdt/index_zxdt.html')
html = response.read().decode('utf-8')
#print html

#pattern = re.compile('<div id="newList">.*?<li>.*?<a href="(.*?)".*?</a>.*?<span class="zxdt_time_in">(.*?)</span>',re.S)
pattern = re.compile('<div id="newList">.*?<ul>(.*?)</ul>.*?</div>',re.S)
items = re.findall(pattern,html)
print items
print items.__len__()

pattern1 = re.compile('<li><a href=".*?".*?>(.*?)</a>.*?</li>',re.S)
items1 = re.findall(pattern1,items[0])
print items1
print items1.__len__()
for item1 in items1:
    print item1
